<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

<title>搜索页面</title>

<link href="<%=path%>/web/assets/css/amazeui.css" rel="stylesheet"
	type="text/css" />
<link href="<%=path%>/web/assets/css/admin.css" rel="stylesheet"
	type="text/css" />

<link href="<%=path%>/web/basic/css/demo.css" rel="stylesheet"
	type="text/css" />

<link href="<%=path%>/web/css/seastyle.css" rel="stylesheet"
	type="text/css" />

<script type="text/javascript"
	src="<%=path%>/web/basic/js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="<%=path%>/web/js/script.js"></script>
<%-- <script src="<%=path%>/web/js/myJQuery.js"></script>  --%>

<script type="text/javascript">
function addShopCar(userId,commodityId){
	//alert(userId);
	//alert(commodityId);
	var num=$(".checkNum").html();
	//alert(num);
	if(num>0){
	jQuery.ajax({
	       type: "POST",
	       url: "<%=path%>/shopcar/addShopcart.do?userId="+userId+"&commodityId="+commodityId,
	       dataType:"json",
	       success: function(data){
	               alert("添加购物车成功！")
	          },
	   error:function(){
	  	 alert("添加购物车失败"); 
	    }
	    });
	num=num-1;
	$(".checkNum").html(num);
	}else{
		alert("库存不足！")
	}
}



function logOut(){
	//Ajax调用处理
	jQuery.ajax({
	    type: "POST",
	    url: "<%=path %>/user/logOut.do",
	    dataType:"json",
	    success: function(data){
	    	 alert("操作成功"); 
	         alert(data.SUCCESS);
	         location.reload(true);
	       },
	    error:function(){
		 alert("操作失败"); 
	   }
	 });
	 
	}

</script>
<title>搜索结果页面</title>
</head>
<body>

	<!--顶部导航条 -->
	<div class="am-container header">
		<ul class="message-l">
			<div class="topMessage">
				<div class="menu-hd">
				<c:choose> 
					<c:when test="${userInfoSession!=null}">
					    <a href="<%=path %>/web/user/login.jsp" target="_top" class="h">欢迎${userInfoSession.userName}</a> 
					    <EM  onclick="logOut()">退出</EM>
					</c:when>
					<c:otherwise>
						<a href="<%=path %>/web/user/login.jsp" target="_top" class="h">亲，请登录</a> 
						<a href="user/signUp.jsp" target="_top">免费注册</a>
					</c:otherwise>
					</c:choose>
				</div>
			</div>
		</ul>
		<ul class="message-r">
			<div class="topMessage home">
				<div class="menu-hd">
					<a href="<%=path %>/adv/queryAdvWeb.do" target="_top" class="h">商城首页</a>
				</div>
			</div>
			<div class="topMessage my-shangcheng">
				<div class="menu-hd MyShangcheng">
					<a href="#" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a>
				</div>
			</div>
			<div class="topMessage mini-cart">
				<div class="menu-hd">
					<a id="mc-menu-hd" href="<%=path %>/shopcar/queryShopcarInfo.do" target="_top"><i
						class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong
						id="J_MiniCartNum" class="h">0</strong></a>
				</div>
			</div>
			<div class="topMessage favorite">
				<div class="menu-hd">
					<a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a>
				</div>
		</ul>
	</div>

	<!--悬浮搜索框-->

	<div class="nav white">
		<div class="logo">
			<img src="<%=path%>/web/images/logo.png" />
		</div>
		<div class="logoBig">
			<li><img src="<%=path%>/web/images/logobig.png" /></li>
		</div>

		<div class="search-bar pr">
			<a name="index_none_header_sysc" href="#"></a>
			<form action="<%=path%>/commodity/queryCommodityWeb.do" method="post">
				<input id="searchInput" name="name" type="text" placeholder="搜索"
					autocomplete="off"> <input id="ai-topsearch"
					class="submit am-btn" value="搜索" index="1" type="submit">
			</form>
		</div>
	</div>
	<br>
	<br>
	<br>
	<br>
	<div class="clear"></div>
	<b class="line"></b>
	<div class="search">
		<div class="search-list">

			<div class="am-g am-g-fixed">
				<div class="am-u-sm-12 am-u-md-12">

					<div class="search-content">

						<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes">

							<c:choose>
								<c:when test="${commodities.size() eq 0}">
									<li>
										<div class="i-pic limit">搜索结果为空！</div>
									</li>
								</c:when>

								<c:otherwise>
									<c:forEach items="${requestScope.commodities}" var="commodity">
								
										<li>
											<div class="i-pic limit">

												<c:if test="${commodity.imgs!=null}">
													<a
														href="<%=path %>/commodity/queryCommodityWeb.do?id=${commodity.id}&detail=1">
														<img src="<%=path%>/Imgs/${commodity.imgs[0].imgName}" />
													</a>
												</c:if>
												<p class="title fl">${commodity.name}</p>
												<p class="price fl">
													<b>¥</b> <strong>${commodity.price}</strong>
												</p>
												<p class="number fl">
                                                    <b class="checkNum" >${commodity.number }</b>
													<img style="width: 25px; height: 25px;"
														src="<%=path%>/web/images/shopping.png" /> 
												     <a class="price" onclick="addShopCar(${sessionScope.userInfoSession.id},${commodity.id})">加入购物车</a>
												</p>
											</div>
										</li>

									</c:forEach>
								</c:otherwise>
							</c:choose>



						</ul>
					</div>
					<div class="search-side">

						<div class="side-title">经典搭配</div>

						<li>
							<div class="i-pic check">
								<img src="<%=path%>/web/images/cp.jpg" />
								<p class="check-title">萨拉米 1+1小鸡腿</p>
								<p class="price fl">
									<b>¥</b> <strong>29.90</strong>
								</p>
								<p class="number fl">
									销量<span>1110</span>
								</p>
							</div>
						</li>
						<li>
							<div class="i-pic check">
								<img src="<%=path%>/web/images/cp2.jpg" />
								<p class="check-title">ZEK 原味海苔</p>
								<p class="price fl">
									<b>¥</b> <strong>8.90</strong>
								</p>
								<p class="number fl">
									销量<span>1110</span>
								</p>
							</div>
						</li>
						<li>
							<div class="i-pic check">
								<img src="<%=path%>/web/images/cp.jpg" />
								<p class="check-title">萨拉米 1+1小鸡腿</p>
								<p class="price fl">
									<b>¥</b> <strong>29.90</strong>
								</p>
								<p class="number fl">
									销量<span>1110</span>
								</p>
							</div>
						</li>

					</div>
					<div class="clear"></div>
					<!--分页 -->
					<ul class="am-pagination am-pagination-right">
						<li class="am-disabled"><a href="#">&laquo;</a></li>
						<li class="am-active"><a href="#">1</a></li>
						<li><a href="#">2</a></li>
						<li><a href="#">3</a></li>
						<li><a href="#">4</a></li>
						<li><a href="#">5</a></li>
						<li><a href="#">&raquo;</a></li>
					</ul>

				</div>
			</div>
			<div class="footer">
				<div class="footer-hd">
					<p>
						<a href="#">恒望科技</a> <b>|</b> <a href="#">商城首页</a> <b>|</b> <a
							href="#">支付宝</a> <b>|</b> <a href="#">物流</a>
					</p>
				</div>
				<div class="footer-bd">
					<p>
						<a href="#">关于恒望</a> <a href="#">合作伙伴</a> <a href="#">联系我们</a> <a
							href="#">网站地图</a> <em>© 2015-2025 Hengwang.com 版权所有. 更多模板 <a
							href="http://www.cssmoban.com/" target="_blank" title="模板之家">模板之家</a>
							- Collect from <a href="http://www.cssmoban.com/" title="网页模板"
							target="_blank">网页模板</a></em>
					</p>
				</div>
			</div>
		</div>

	</div>

	<!--引导 -->
	<div class="navCir">
		<li><a href="home2.html"><i class="am-icon-home "></i>首页</a></li>
		<li><a href="sort.html"><i class="am-icon-list"></i>分类</a></li>
		<li><a href="shopcart.html"><i
				class="am-icon-shopping-basket"></i>购物车</a></li>
		<li><a href="<%=path%>/web/person/index.html"><i
				class="am-icon-user"></i>我的</a></li>
	</div>

	<!--菜单 -->
	<div class=tip>
		<div id="sidebar">
			<div id="wrap">
				<div id="prof" class="item">
					<a href="#"> <span class="setting"></span>
					</a>
					<div class="ibar_login_box status_login">
						<div class="avatar_box">
							<p class="avatar_imgbox">
								<img src="<%=path%>/web/images/no-img_mid_.jpg" />
							</p>
							<ul class="user_info">
								<li>用户名：sl1903</li>
								<li>级&nbsp;别：普通会员</li>
							</ul>
						</div>
						<div class="login_btnbox">
							<a href="#" class="login_order">我的订单</a> <a href="#"
								class="login_favorite">我的收藏</a>
						</div>
						<i class="icon_arrow_white"></i>
					</div>

				</div>
				<div id="shopCart" class="item">
					<a href="#"> <span class="message"></span>
					</a>
					<p>购物车</p>
					<p class="cart_num">0</p>
				</div>
				<div id="asset" class="item">
					<a href="#"> <span class="view"></span>
					</a>
					<div class="mp_tooltip">
						我的资产 <i class="icon_arrow_right_black"></i>
					</div>
				</div>

				<div id="foot" class="item">
					<a href="#"> <span class="zuji"></span>
					</a>
					<div class="mp_tooltip">
						我的足迹 <i class="icon_arrow_right_black"></i>
					</div>
				</div>

				<div id="brand" class="item">
					<a href="#"> <span class="wdsc"><img
							src="<%=path%>/web/images/wdsc.png" /></span>
					</a>
					<div class="mp_tooltip">
						我的收藏 <i class="icon_arrow_right_black"></i>
					</div>
				</div>

				<div id="broadcast" class="item">
					<a href="#"> <span class="chongzhi"><img
							src="<%=path%>/web/images/chongzhi.png" /></span>
					</a>
					<div class="mp_tooltip">
						我要充值 <i class="icon_arrow_right_black"></i>
					</div>
				</div>

				<div class="quick_toggle">
					<li class="qtitem"><a href="#"><span class="kfzx"></span></a>
						<div class="mp_tooltip">
							客服中心<i class="icon_arrow_right_black"></i>
						</div></li>
					<!--二维码 -->
					<li class="qtitem"><a href="#none"><span
							class="mpbtn_qrcode"></span></a>
						<div class="mp_qrcode" style="display: none;">
							<img src="<%=path%>/web/images/weixin_code_145.png" /><i
								class="icon_arrow_white"></i>
						</div></li>
					<li class="qtitem"><a href="#top" class="return_top"><span
							class="top"></span></a></li>
				</div>

				<!--回到顶部 -->
				<div id="quick_links_pop" class="quick_links_pop hide"></div>

			</div>

		</div>
		<div id="prof-content" class="nav-content">
			<div class="nav-con-close">
				<i class="am-icon-angle-right am-icon-fw"></i>
			</div>
			<div>我</div>
		</div>
		<div id="shopCart-content" class="nav-content">
			<div class="nav-con-close">
				<i class="am-icon-angle-right am-icon-fw"></i>
			</div>
			<div>购物车</div>
		</div>
		<div id="asset-content" class="nav-content">
			<div class="nav-con-close">
				<i class="am-icon-angle-right am-icon-fw"></i>
			</div>
			<div>资产</div>

			<div class="ia-head-list">
				<a href="#" target="_blank" class="pl">
					<div class="num">0</div>
					<div class="text">优惠券</div>
				</a> <a href="#" target="_blank" class="pl">
					<div class="num">0</div>
					<div class="text">红包</div>
				</a> <a href="#" target="_blank" class="pl money">
					<div class="num">￥0</div>
					<div class="text">余额</div>
				</a>
			</div>

		</div>
		<div id="foot-content" class="nav-content">
			<div class="nav-con-close">
				<i class="am-icon-angle-right am-icon-fw"></i>
			</div>
			<div>足迹</div>
		</div>
		<div id="brand-content" class="nav-content">
			<div class="nav-con-close">
				<i class="am-icon-angle-right am-icon-fw"></i>
			</div>
			<div>收藏</div>
		</div>
		<div id="broadcast-content" class="nav-content">
			<div class="nav-con-close">
				<i class="am-icon-angle-right am-icon-fw"></i>
			</div>
			<div>充值</div>
		</div>
	</div>
	<script>
		window.jQuery
				|| document
						.write('<script src="basic/js/jquery-1.9.min.js"><\/script>');
	</script>
	<script type="text/javascript"
		src="<%=path%>/web/basic/js/quick_links.js"></script>

	<div class="theme-popover-mask"></div>

</body>
</html>